import { download, ffmpeg, fileutil } from '../index.js'
const { getImage, getM3u8, getVideo } = ffmpeg;
const { deldir } = fileutil;
import fs from 'fs'
import test from 'ava'

test.before(async t => {
  let videoUrl = `https://minioapi.byyui.com:9999/zztemp/test.mp4`;
  let ins = new download(videoUrl, './test.mp4');
  await ins.download();
})

test('getImage', async t => {
  
  await getImage('./test.mp4', './test.png');
  let rs = fs.existsSync('./test.png');
  t.is(rs, true);
  
});

test('getM3u8', async t => {
  await getM3u8('./test.mp4', './testm3u8', 1);
  let rs = fs.existsSync('./testm3u8/index.m3u8');
  t.is(rs, true);
});

test('getVideo', async t => {
  await getVideo('./test.mp4', 0, 3, './1.mp4');
  let rs = fs.existsSync('./1.mp4');
  t.true(rs);
})

test.after('cleanup',t=>{
  deldir('./test.png');
  deldir('./testm3u8');
  deldir('./test.mp4');
  deldir('./1.mp4');
})